{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header"></div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"
            ></table>

            <input type="hidden" id="adminId" value="{$adminId}">
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    layui.use('yznTable', function () {
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: '{:url("add")}',
            edit_url: '{:url("edit")}',
            delete_url: '{:url("del")}',
            modify_url: "{:url('multi')}",
            recyclebin_url: "{:url('recyclebin')}",
        };


        var cloumns = [
            {type: 'checkbox', fixed: 'left'},
            {field: 'id', title: 'id', minWidth: 80},
            {field: 'cate.cate_name', title: '分类名称', minWidth: 80, searchOp: 'LIKE', minWidth: 110},
            {field: 'title', title: '标题', minWidth: 80, searchOp: 'LIKE', minWidth: 110},
            {
                field: 'kind',
                align: 'center',
                title: '类型',
                templet: yznTable.formatter.label,
                selectList: {2: '图片', 4: '视频'}
            },

            {
                field: 'hashtag',
                title: '标签',
                minWidth: 80,
                searchOp: 'LIKE',
                minWidth: 110,
                templet: yznTable.formatter.flag
            },
            {
                field: 'status',
                align: 'center',
                width: 120,
                search: false,
                title: '状态',
                unresize: true,
                templet: yznTable.formatter.switch,
                tips: "正常|冻结"
            },
            {field: 'sort', title: '排序', minWidth: 80},
            {
                field: 'create_time',
                title: '创建时间',
                minWidth: 80,
                width: 180,
                search: 'range',
                templet: yznTable.formatter.datetime
            },
            {
                field: 'is_lock',
                align: 'center',
                width: 120,
                search: false,
                title: '是否锁定',
                unresize: true,
                templet: yznTable.formatter.switch,
                tips: "是|否"
            },
            {
                fixed: 'right',
                width: 90,
                field: 'operate',
                title: '操作',
                templet: yznTable.formatter.tool,
                operat: ['edit', 'delete']
            }
        ]
           var admin =  ['refresh', 'add', 'delete']
        var adminId = $('#adminId').val();
        if (adminId == 1) {
            cloumns.splice(2, 0, {field: 'admin.username', title: '团队', searchOp: 'like'});
            var admin = ['refresh', 'delete']
        }
        table.render({
            init: init,
            toolbar: admin,
            url: '{:url("index")}',
            cols: yznTable.formatCols([cloumns], init),
            page: {}
        });

        yznTable.bindevent();
    });
</script>
{/block}